<?php

namespace AdminPanel\NewsBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

use AdminPanel\NewsBundle\Entity\News;


class NewsType extends AbstractType
{
  
    protected $em;


    public function __construct($em = null)
    {
      $this->em = $em;
    }
  
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
      
      
      $categoryArray = News::getContentCategoryListValues($this->em);      
      $newList = array(0=>'Сонгох');
      foreach ($categoryArray AS $category)
      {
        $newList[$category['category_id']] = $category['category_name'];
      }
      
        $builder
            ->add('categoryId', 'choice', array('choices' => $newList, 'expanded' => false))
            ->add('newsTitle')
            ->add('newsBody')            
            ->add('imgThumb', 'text', array('label' => 'Мэдээний жижиг зураг', 'required' => false))
            ->add('imgLarge', 'text', array('label' => 'Мэдээний том зураг', 'required' => false))            
            ->add('isSpecial')
            ->add('isActive')
            ->add('targetDate')
//            ->add('createdAt')
//            ->add('createdUserId')
//            ->add('updatedAt')
//            ->add('updatedId')
//            ->add('updatedUserIp')
        ;
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AdminPanel\NewsBundle\Entity\News'
        ));
    }

    public function getName()
    {
        return 'adminpanel_newsbundle_newstype';
    }
}
